﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Biz.Process
{
    public class Cmd2051Sqls
    {
        //主
        public static string M_EXIST = "SELECT COUNT(1) FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[主分钟数据_企业ID]') AND type IN('U')";
        public static string M_CREATE = "CREATE TABLE [dbo].[主分钟数据_企业ID] ([ID] int  IDENTITY(1,1) NOT NULL,[企业排口ID] int  NOT NULL,[监测时间] datetime  NOT NULL,[污染物类别ID] int  NOT NULL,[时段量] float(53)  NOT NULL)";
        public static string M_ALTER_1 = "ALTER TABLE [dbo].[主分钟数据_企业ID] SET (LOCK_ESCALATION = TABLE)";
        public static string M_ALTER_2 = "ALTER TABLE [dbo].[主分钟数据_企业ID] ADD CONSTRAINT [PK_主分钟数据_企业ID] PRIMARY KEY CLUSTERED ([ID]) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  ON [PRIMARY]";

        public static string M_NONCLUSTERED_1 = "CREATE NONCLUSTERED INDEX [IDX_主分钟数据企业ID_企业排口ID] ON [dbo].[主分钟数据_企业ID] ([企业排口ID] ASC)";
        public static string M_NONCLUSTERED_2 = "CREATE NONCLUSTERED INDEX [IDX_主分钟数据企业ID_污染物类别ID] ON [dbo].[主分钟数据_企业ID] ([污染物类别ID] ASC)";
        public static string M_NONCLUSTERED_3 = "CREATE NONCLUSTERED INDEX [IDX_主分钟数据企业ID_监测时间] ON [dbo].[主分钟数据_企业ID] ([监测时间] DESC)";

        public static string M_UPDATE = "UPDATE [主分钟数据_企业ID] SET [企业排口ID] = {企业排口ID},[监测时间] = {监测时间},[污染物类别ID] = {污染物类别ID},[时段量] = {时段量} WHERE {搜索条件}";
        public static string M_INSERT = "INSERT INTO [主分钟数据_企业ID]([企业排口ID],[监测时间],[污染物类别ID],[时段量])VALUES({企业排口ID},{监测时间},{污染物类别ID},{时段量})";
        public static string M_SELECT = "SELECT COUNT(1) FROM [主分钟数据_企业ID] WHERE {搜索条件} ";
        //从
        public static string D_EXIST = "SELECT COUNT(1) FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[从分钟数据_企业ID]') AND type IN ('U')";
        public static string D_CREATE = "CREATE TABLE [dbo].[从分钟数据_企业ID] ([ID] int  IDENTITY(1,1) NOT NULL,[主分钟数据ID] int  NOT NULL,[污染物编码ID] int  NOT NULL,[Cou] float(53)  NOT NULL,[Min] float(53)  NULL,[Avg] float(53)  NULL,[Max] float(53)  NULL,[ZSCou] float(53)  NULL,[ZSMin] float(53)  NULL,[ZSAvg] float(53)  NULL,[ZSMax] float(53)  NULL)";
        public static string D_ALTER_1 = "ALTER TABLE [dbo].[从分钟数据_企业ID] SET (LOCK_ESCALATION = TABLE)";
        public static string D_ALTER_2 = "ALTER TABLE [dbo].[从分钟数据_企业ID] ADD CONSTRAINT [PK_从分钟数据_企业ID] PRIMARY KEY CLUSTERED ([ID]) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]";
        public static string D_NONCLUSTERED_1 = "CREATE NONCLUSTERED INDEX [IDX_从分钟数据企业ID_企业ID_主数据ID] ON [dbo].[从分钟数据_企业ID] ([主分钟数据ID] ASC)";
        public static string D_NONCLUSTERED_2 = "CREATE NONCLUSTERED INDEX [IDX_从分钟数据企业ID_污染物编码ID] ON [dbo].[从分钟数据_企业ID] ([污染物编码ID] ASC)";

        public static string D_UPDATE = "UPDATE [从分钟数据_企业ID] SET [主分钟数据ID] = {主分钟数据ID},[污染物编码ID] = {污染物编码ID},[Cou] = {Cou},[Min] ={Min},[Avg] = {Avg},[Max] ={Max},[ZSCou] = {ZSCou},[ZSMin] ={ZSMin},[ZSAvg] = {ZSAvg},[ZSMax] ={ZSMax} WHERE {搜索条件}";
        public static string D_INSERT = "INSERT INTO [从分钟数据_企业ID]([主分钟数据ID],[污染物编码ID],[Cou],[Min],[Avg],[Max],[ZSCou],[ZSMin],[ZSAvg],[ZSMax])VALUES({主分钟数据ID},{污染物编码ID},{Cou},{Min},{Avg},{Max},{ZSCou},{ZSMin},{ZSAvg},{ZSMax})";
        public static string D_SELECT = "SELECT COUNT(1) FROM [从分钟数据_企业ID] WHERE {搜索条件} ";



    }
}
